import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:qgchat/common/global/global.dart';

import 'BloC/likesBloC.dart';

///
/// 点赞组件
///

class Likes extends StatelessWidget {
  const Likes({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final LikesBloc likesBloc = LikesBloc();
    return BlocBuilder<LikesBloc, bool>(
      bloc: likesBloc,
      builder: (context, isLikes) {
        String likesUrl = "assets/images/icon/likes.png";
        String nolikesUrl = "assets/images/icon/nolikes.png";

        return Container(
          width: px(75),
          height: px(50),
          child: FlatButton.icon(
            onPressed: () => likesBloc.add(LikesEvent.confirm),
            padding: EdgeInsets.zero,
            icon: Image.asset(
              "${isLikes ? likesUrl : nolikesUrl}",
              width: px(32),
              height: px(30),
            ),
            label: Text(
              "0",
              style: TextStyle(
                color: col("303133"),
                fontSize: px(24),
              ),
            ),
          ),
        );
      },
    );
  }
}
